<%@ page language="java" import="java.util.*" pageEncoding="utf-8" contentType="text/html;charset=UTF-8"%>
<%@ page import="com.javahash.spring.classes.User"%>
<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<script type="text/javascript">
	function ClickAdd(elim){
		document.getElementById("hd").value=elim.id;
		document.getElementById("tableform").submit();
	}
	
	function ClickDel(elim, tid, tname){
		document.getElementById("hd").value=elim;
		document.getElementById("del_id").value=tid;
		document.getElementById("del_name").value=tname;
		document.getElementById("tableform").submit();
	}
</script>
<title>Insert title here</title>
</head>
<script type="text/javascript">
</script>
<body>
	<form id="tableform" action="Cz" method="post">
	<input id="hd" name="hd" type="text" value=""/>
	<input id="del_id" name="del_id" type="hidden" value="" />
	<input id="del_name" name="del_name" type="hidden" value="" />
		<table cellspacing="0" border="1">
			<thead>
				<tr>
					<td align="center"  width="50px">ID</td>
					<td align="center"  width="50px">Name</td>
					<td align="center"  width="50px">method1</td>
					<td align="center"  width="50px">method2</td>
				</tr>
			</thead>
			<% 
			List<User> us = (List<User>)request.getAttribute("users");
			if(us.size()>=1)
			{
				for(int i=0;i<us.size(); i++)
				{
					User u = new User();
					u = us.get(i);
					%>
<%-- 					<script>
						alert(l=<%=u.getId()%>);
					</script> --%>
					
					<tr>
						<td align="center"  width="50px">
							<%=u.getId()%>
						</td>
						<td align="center"  width="50px">
							<%=u.getName()%>
						</td>
						<td align="center"  width="50px">
							<input id="delete" type="button" value="delete" onclick="ClickDel(this.value,id='<%=u.getId() %>',name='<%=u.getName() %>')" />	
						</td>
						<td align="center"  width="50px">
							<input id="add" type="button" value="add" disabled="disabled"/>
						</td>
					</tr>
					<%
				}
			}
			%>
			<tr>
				<td align="center"  width="50px"><input name="txt_id" type="text" value="" /></td>
				<td align="center"  width="50px"><input name="txt_name" type="text" value=""/></td>
				<td align="center"  width="50px"><input id="delete" type="button" value="Delete" disabled="disabled"/></td>
				<td align="center"  width="50px"><input id="add" type="button" value="Add" onclick="ClickAdd(this)"/></td>
			</tr>
		</table>
	</form>
</body>
</html>